package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.EduSchool;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.domain.vo.SchoolVo;
import com.ruoyi.system.service.IEduSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/edu/school")
public class EduController extends BaseController {

    @Autowired
    private IEduSchoolService eduSchoolService;


    @PreAuthorize("@ss.hasPermi('edu:school:list')")
    @GetMapping("/list")
    public TableDataInfo list(SchoolVo school)
    {
        startPage();
        List<SchoolVo> list = eduSchoolService.selectEduSchoolList(school);
        return getDataTable(list);
    }

    @Log(title = "导出", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('edu:school:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchoolVo school)
    {
        List<SchoolVo> list = eduSchoolService.selectEduSchoolList(school);
        ExcelUtil<SchoolVo> util = new ExcelUtil<SchoolVo>(SchoolVo.class);
        util.exportExcel(response, list, "院校列表");
    }

}
